package com.zhuchaooasystem.widget;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.zhuchaooasystem.R;


/**
 * @author yinsi
 */
public class OkDialog extends Dialog {

    private TextView text_content;
    private Button btn_ok;
    //----
    private OnOkClickListener listenner;

    public OkDialog(Context context) {
        super(context);
    }

    protected OkDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    public OkDialog(Context context, int themeResId) {
        super(context, themeResId);
    }

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        try {
            setContentView(R.layout.dlg_ok);
            //----
            text_content = (TextView) findViewById(R.id.dialog_ok_tv_content);
            btn_ok = (Button) findViewById(R.id.dialog_ok_tv_ok);
            btn_ok.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    if (listenner != null) {
                        listenner.onClick(OkDialog.this);
                    } else {
                        dismiss();
                    }
                }
            });
        } catch (Exception e) {
        }
    }

    public void setTextContent(String content) {
        try {
            if (null != text_content) {
                text_content.setText(content);
            }
        } catch (Exception e) {
        }
    }

    public interface OnOkClickListener {
        void onClick(OkDialog dialog);
    }

    public void setOnOkClickListener(OnOkClickListener listener) {
        this.listenner = listener;
    }

}
